fix(datasource): restrict maven registries parsed from pom.xml#2713
Closed
TristanInSec wants to merge 1 commit intogoogle:mainfrom
Closed
fix(datasource): restrict maven registries parsed from pom.xml#2713TristanInSec wants to merge 1 commit intogoogle:mainfrom
TristanInSec wants to merge 1 commit intogoogle:mainfrom
Conversation
Registries added through MavenRegistryAPIClient.AddRegistry typically originate from <repositories> blocks inside pom.xml files, which are attacker-controlled input when scanning third-party projects. Two tightenings: - Validate untrusted registry URLs: require http/https, and reject hosts that resolve to loopback, private, link-local, unspecified, or multicast addresses. The default registry passed to NewMavenRegistryAPIClient is exempt so users can still point osv-scanner at internal Artifactory/Nexus mirrors. - Only attach settings.xml <server> credentials to the default registry. Registries added later via AddRegistry are marked TrustedForAuth=false and receive no auth, so a pom.xml-declared repository cannot pull credentials scoped to an unrelated host. Unit tests cover the scheme/host rejection paths and the credential-gating behaviour in getProject, getVersionMetadata, and getArtifactMetadata.
Collaborator
|
@TristanInSec thank you for your contribution! We are migrating all our native registry clients to osv-scalibr - please make your contribution with osv-scalibr instead. There is an issue for this: google/osv-scalibr#1877 |
4 tasks
Author
|
Thanks for the heads up — ported the fix to osv-scalibr in google/osv-scalibr#1970 (against #1877). Happy to iterate there. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tightens how
internal/datasource/maven_registry.gohandles<repositories>entries pulled from parsedpom.xmlfiles, which are untrusted input when osv-scanner walks a third-party project:AddRegistrynow rejects non-http(s)schemes and hosts that resolve to loopback / private / link-local / unspecified / multicast addresses. The default registry passed toNewMavenRegistryAPIClientis intentionally exempt so internal Artifactory/Nexus mirrors keep working.MavenRegistry.TrustedForAuthflag is set only on the default registry.getProject,getVersionMetadata, andgetArtifactMetadataroute through a newauthFor()helper that returnsnilfor registries added frompom.xml, sosettings.xml<server>credentials can no longer be sent to a repository URL declared inside a dependency's manifest.Testing
go test ./internal/datasource/...— passes, including new tests for scheme rejection, private-IP rejection, and the credential-gating paths.go build ./...— clean.